import { reactive } from 'vue'
import { getSettingRoleList } from '@src/api/SettingApi';
import { getButtonConcatTriggerList } from '@src/api/SystemApi';

export const commonStore = reactive({
    // 角色列表
    roleList:[],
    roleListIsIniting:false,
    initRoleList(){
        if(this.roleListIsIniting === true){
            return
        }
        this.roleListIsIniting = true
        getSettingRoleList({pageSize:0,}).then(res=>{
            this.roleList = res.list || []
        }).finally(()=>{
            this.roleListIsIniting = false
        })
    },
    getRoleList(){
        return this.roleList
    },

    // 获取容器化的页面按钮能触发的触发器列表
    ButtonSetChooseUpdateTriggerList:[],
    ButtonSetChooseUpdateTriggerListIsIniting:false,
    getButtonSetChooseUpdateTriggerList(){
        return this.ButtonSetChooseUpdateTriggerList
    },
    initButtonSetChooseUpdateTriggerList(params: any={}){
        if(this.ButtonSetChooseUpdateTriggerListIsIniting === true){
            return
        }
        this.ButtonSetChooseUpdateTriggerListIsIniting = true
        getButtonConcatTriggerList(params).then(res=>{
            if(res.status === 0){
                this.ButtonSetChooseUpdateTriggerList = res.data
            }
        }).finally(()=>{
            this.ButtonSetChooseUpdateTriggerListIsIniting = false
        })

    }
})